package com.baijiaoxi.common.model;

import com.google.gson.Gson;
import lombok.Getter;
import lombok.Setter;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;

public class AreaJson {


    public class OriginAresJson {
        @Getter
        @Setter
        protected Map<Integer, String> province_list;
        @Getter
        @Setter
        protected Map<Integer, String> city_list;
        @Getter
        @Setter
        protected Map<Integer, String> county_list;
    }

    @Getter
    protected OriginAresJson originAresJson;

    public Map<Integer, String> getProvinceList() {
        return originAresJson.getProvince_list();
    }

    public Map<Integer, String> getCityList() {
        return originAresJson.getCity_list();
    }

    public Map<Integer, String> getCountyList() {
        return originAresJson.getCity_list();
    }

    public AreaJson(String jsonPath) throws IOException {
        this.originAresJson = new Gson().fromJson(Files.readString(Path.of(jsonPath)), OriginAresJson.class);
    }
}
